#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9;

bool isgoodsimple(const string &s) {
    int len = s.length();
    if (len == 0)
        return false;

    for (int p = 1; p <= len / 2; ++p) {
        if (len % p == 0) {

            string t = s.substr(0, p);
            bool isp = true;

            for (int k = p; k < len; k += p) {
                if (s.substr(k, p) != t) {
                    isp = false;
                    break;
                }
            }

            if (isp) {
                return false;
            }
        }
    }

    return true;
}

void solve() {
    string s;
    cin >> s;
    int n = s.length();

    vector<int> dp(n + 1, INF);

    vector<long long> cnt(n + 1, 0);

    dp[0] = 0;
    cnt[0] = 1;

    for (int i = 1; i <= n; ++i) {

        for (int j = 0; j < i; ++j) {

            string sub = s.substr(j, i - j);

            if (isgoodsimple(sub)) {

                if (dp[j] == INF)
                    continue;

                if (dp[j] + 1 < dp[i]) {

                    dp[i] = dp[j] + 1;
                    cnt[i] = cnt[j];
                } else if (dp[j] + 1 == dp[i]) {

                    cnt[i] = (cnt[i] + cnt[j]) % MOD;
                }
            }
        }
    }

    cout << dp[n] << endl;
    cout << cnt[n] << endl;
}

int main() {

    iostream::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}
